<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title><?php echo C("SITE_NAME");?>管理后台</title>
<link rel="shortcut icon" href=" /favicon.ico" />
<link rel="stylesheet" href="/Static/admin/css/component-min.css">
<link rel="stylesheet" href="/Static/admin/css/home.2015.05.22-09.32.css">
<link rel="stylesheet" href="/Static/admin/icon/iconfont.css">
<!--弹窗-->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script src="/Static/admin/js/layer-2.x/layer.js?v=1.9.0"></script>
<script src="/Static/admin/js/common.js"></script>
<script>
	var UPYUN_DOMAIN = '<?php echo C("UPYUN_DOMAIN");?>';
</script>
</head>
<body class="cp-bodybox">
<!--[if lt IE 9]>
<div class="alert alert-danger disable-del txtCenter" id="tipLowIEVer">
    <h4>系统检测到您使用的浏览器版本过低，为达到更好的体验效果请升级您的浏览器，我们为您推荐：</h4>
    <p>
        <a href="http://www.firefox.com.cn/download/" target="_blank">Firefox浏览器</a>
        <a href="http://www.maxthon.cn/" target="_blank">遨游浏览器</a>
        <a href="http://se.360.cn/" target="_blank">360浏览器</a>
    </p>
</div>
<![endif]-->
<style>
.header-nav-list a {
  display: block;
  padding: 0 10px;
  min-width: 70px;
  line-height: 53px;
  font-size: 14px;
  text-align: center;
  font-weight: 700;
}
</style>

<div class="header">
    <div class="inner clearfix">
        <div class="fl">
            <a href="/" class="header-logo">
                <img
                    src="<?php echo C('UPYUN_DOMAIN'); echo C('SITE_TOPLOGO2');?>"
                    onerror="javascript:this.src='/Static/admin/images/error.png';"
                    ></a>
        </div>
        <!-- end logo -->

        <div class="header-nav fl">
            <ul class="header-nav-list clearfix">
                <!--<li class="fl <?php echo ($controller == 'index')?'active':'';?>"><a href="/admin">首页</a></li>-->
                <?php foreach($MENU as $k=>$v){?>
                <li class="fl <?php echo ($controller == $v['controller'])?'active':'';?>">
                    <a href="<?php echo $v['url'];?>"><?php echo $v['title'];?></a>
                </li>
                <?php } ?>
            </ul>
        </div>
        <!-- end header-nav -->

        <div class="fr">
            <ul class="header-ctrl clearfix">
                <li class="header-ctrl-item fl"><a href="/admin/login/logout">退出</a></li>
            </ul>
        </div>

        <span class="account_inbox_switch fr"></span>
        <span class="header-welcome fr">
            <a href="javasecript:;" class="tips" data-trigger="hover" data-placement="top"><?php echo $admininfo['username'];?></a>
        </span>

    </div>
</div>
<!-- end header -->
	<div class="container">
		<div class="inner clearfix">
	<div class="content-left fl">
    <?php foreach($SUBMENU as $subkey=>$sub){ ?>
    <dl class="left-menu shop_8">
        <dt>
            <i class="icon-menu home"></i> <span id="shop_0" data-id="0"><?=$sub['title']?></span>
        </dt>
        <?php foreach($sub['menu'] as $menu){ ?>
        <dd class="<?php echo ($action == $menu["action"])?'active':'';?>">
            <a href="<?=$menu['url']?>"><?=$menu['title']?></a>
        </dd>
        <?php } ?>
    </dl>
    <?php } ?>
</div>
<link rel="stylesheet" type="text/css" href="/Static//admin/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="/Static//admin/css/tree.css" />

<style>
    .container,
    .navbar-static-top .container,
    .navbar-fixed-top .container,
    .navbar-fixed-bottom .container {
        width: auto;
    }

    a {
        color: #000
    }

    a,
    a:link,
    a:hover {
        text-decoration: none
    }
</style>
<div id="app" class="content-right fl">
    <div class="tree well">
        <ul>
            <li class="parent_li">
                <span title="Collapse this branch"><i class="icon-minus-sign"></i>中国</span>
                <ul>
                    <li class="parent_li" v-for="(province,provinceIndex) in provinceList">
                        <span @click="chooseProvince(provinceIndex)" ><i class="icon-plus-sign"></i>{{province.area_name}}</span>
                        <a @click.self="changeMoney(province.area_id,[provinceIndex,-1])" class="label label-important">{{province.money}}</a>
                        <a v-if="province.is_sale==0" class="label label-default">未签约</a>
                        <a v-if="province.is_sale==1" class="label label-success">已签约</a>
                        <ul>
                            <li class="parent_li" v-for="(item,index) in province.children">
                                <span><i class="icon-leaf"></i>{{item.area_name}}</span>
                                <a @click.self="changeMoney(item.area_id,[provinceIndex,index])" class="label label-important">{{item.money}}</a>
                                <a v-if="item.is_sale==0" class="label label-default">未签约</a>
                                <a v-if="item.is_sale==1" class="label label-success">已签约</a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
</div>
<script src="/Static/mobile/vant/vue.min.js"></script>
<script src="https://cdn.bootcss.com/layer/3.1.0/layer.js"></script>
<script type="text/javascript">
    $(function () {
        $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch');
        $('body').on('click','.tree li.parent_li > span', function (e) {
            var children = $(this).parent('li.parent_li').find(' > ul > li');
            if (children.is(":visible")) {
                children.hide('fast');
                $(this).attr('title', 'Expand this branch').find(' > i').addClass('icon-plus-sign').removeClass('icon-minus-sign');
            } else {
                children.show('fast');
                $(this).attr('title', 'Collapse this branch').find(' > i').addClass('icon-minus-sign').removeClass('icon-plus-sign');
            }
            e.stopPropagation();
        });
    });
    var app = new Vue({
        el: '#app',
        data:{
            provinceList: []
        },
        created: function () {
            this.getProvinceList();
        },
        methods: {
            getProvinceList: function () {
                var self = this;
                $.get('/admin/member/getProvinceList').then(function(res){
                    for(var i=0;i<res.data.length;i++) {
                        self.provinceList.push(res.data[i]);
                    }
                })
            },
            chooseProvince: function (index) {
                var self = this;
                var item = this.provinceList[index];
                if(item.children.length>0) {
                    return false;
                }
                $.get('/admin/member/getProvinceChildren?area_id='+item.area_id).then(function(res){
                    self.provinceList[index].children = [];
                    for(var i=0;i<res.data.length;i++) {
                        self.provinceList[index].children.push(res.data[i]);
                    }
                })
            },
            changeMoney: function (area_id,level) {
                var self = this;
                layer.prompt({title: '请输入该地区代理费用', formType: 2}, function(money, index){
                    var data = {
                        area_id: area_id,
                        money: money
                    };
                    $.ajax({
                        url: '/admin/member/area',
                        data: data,
                        type: 'POST'
                    }).then(function(res){
                        if(level[1]==-1) {
                            self.provinceList[level[0]].money = money;
                        }else{
                            self.provinceList[level[0]].children[level[1]].money = money;
                        }
                    })
                    layer.close(index);
                });
            }
        }
    })
</script>
		</div>
	</div>
<!--gonggao-->
<div class="footer">&copy; <?php echo date("Y");?> <?php echo C("SITE_NAME");?> , Inc. All rights reserved.</div>
<a href="#" id="j-gotop" class="gotop" title="回到顶部" style="right:45px; display: inline;"></a>
<script type="text/javascript">
$(function(){
    var height1=$(".content-right").height();
    var height2=$(".content-left").height();
    if(parseInt(height1) < parseInt(height2)){
        $(".content-right").css({'min-height': height2});
    }
    $(window).scroll(function() {
		$(this).scrollTop() >= 150 ? $("#j-gotop").fadeIn(300) : $("#j-gotop").fadeOut(300)
	});
});
</script>
</body>
</html>